#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define fir first
#define sec second
#define mkp make_pair
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=510,MAXS=1<<8;
int n,p,pri[]={2,3,5,7,11,13,17,19};
LL f[MAXS][MAXS],g[2][MAXS][MAXS];
pair<int,int>v[MAXN];
int main()
{
	n=read();p=read();
	for(int i=2;i<=n;++i)
	{
		v[i]=mkp(i,0);
		for(int j=0;j<8;++j)
			if(v[i].fir%pri[j]==0)
			{
				while(v[i].fir%pri[j]==0)v[i].fir/=pri[j];
				v[i].sec|=(1<<j);
			}
	}
	sort(v+2,v+1+n);
	f[0][0]=1;
	for(int i=2;i<=n;++i)
	{
		if(i==2||v[i].fir==1||v[i].fir!=v[i-1].fir)
		{
			memcpy(g[0],f,sizeof(f));
			memcpy(g[1],f,sizeof(f));
		}
		for(int s1=(1<<8)-1;~s1;--s1)
			for(int s2=(1<<8)-1;~s2;--s2)
			{
				if((s2&v[i].sec)==0)(g[0][s1|v[i].sec][s2]+=g[0][s1][s2])%=p;
				if((s1&v[i].sec)==0)(g[1][s1][s2|v[i].sec]+=g[1][s1][s2])%=p;
			}
		if(i==n||v[i].fir==1||v[i].fir!=v[i+1].fir)
		for(int s1=(1<<8)-1;~s1;--s1)
			for(int s2=(1<<8)-1;~s2;--s2)
				f[s1][s2]=(g[0][s1][s2]+g[1][s1][s2]-f[s1][s2]+p)%p;
	}
	LL ans=0;
	for(int s1=(1<<8)-1;~s1;--s1)
		for(int s2=(1<<8)-1;~s2;--s2)
			if((s1&s2)==0)(ans+=f[s1][s2])%=p;
	printf("%lld\n",ans);
	return 0;
}
